package com.wd.elec.controller.bussiness;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wd.common.core.controller.BaseController;
import com.wd.common.core.domain.HttpResponse;
import com.wd.common.annotation.Log;
import com.wd.common.enums.BusinessType;
import com.wd.elec.domain.AttendHoliday;
import com.wd.elec.service.IAttendHolidayService;
import com.wd.common.utils.poi.ExcelUtil;


/**
 * 假期配置Controller
 * 
 * @author liumingkun
 * @date 2023-11-08
 */
@RestController
@RequestMapping("/attend/holiday")
public class AttendHolidayController extends BaseController
{
    @Resource
    private IAttendHolidayService attendHolidayService;

    /**
     * 查询假期配置列表
     */
    @PreAuthorize("@ss.hasPermi('attend:holiday:list')")
    @GetMapping("/list")
    public HttpResponse list(AttendHoliday attendHoliday)
    {
        startPage();
        List<AttendHoliday> list = attendHolidayService.selectAttendHolidayList(attendHoliday);
        return HttpResponse.successData(getDataTable(list));
    }

    /**
     * 导出假期配置列表
     */
    @PreAuthorize("@ss.hasPermi('attend:holiday:export')")
    @Log(title = "假期配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AttendHoliday attendHoliday)
    {
        List<AttendHoliday> list = attendHolidayService.selectAttendHolidayList(attendHoliday);
        ExcelUtil<AttendHoliday> util = new ExcelUtil<AttendHoliday>(AttendHoliday.class);
        util.exportExcel(response, list, "假期配置数据");
    }

    /**
     * 获取假期配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('attend:holiday:query')")
    @GetMapping(value = "/{holidayId}")
    public HttpResponse getInfo(@PathVariable("holidayId") Long holidayId)
    {
        return successData(attendHolidayService.selectAttendHolidayByHolidayId(holidayId));
    }

    /**
     * 新增假期配置
     */
    @PreAuthorize("@ss.hasPermi('attend:holiday:add')")
    @Log(title = "假期配置", businessType = BusinessType.INSERT)
    @PostMapping
    public HttpResponse add(@RequestBody AttendHoliday attendHoliday)
    {
        return getResult(attendHolidayService.insertAttendHoliday(attendHoliday));
    }

    /**
     * 修改假期配置
     */
    @PreAuthorize("@ss.hasPermi('attend:holiday:edit')")
    @Log(title = "假期配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public HttpResponse edit(@RequestBody AttendHoliday attendHoliday)
    {
        return getResult(attendHolidayService.updateAttendHoliday(attendHoliday));
    }

    /**
     * 删除假期配置
     */
    @PreAuthorize("@ss.hasPermi('attend:holiday:remove')")
    @Log(title = "假期配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{holidayIds}")
    public HttpResponse remove(@PathVariable Long[] holidayIds)
    {
        return getResult(attendHolidayService.deleteAttendHolidayByHolidayIds(holidayIds));
    }
}
